package camel.file;


import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class FileCopierWithCamel {

	private static Logger logger = Logger.getLogger(FileCopierWithCamel.class); 
	public static void main(String args[]) throws Exception {
		 // create CamelContext
        CamelContext context = new DefaultCamelContext();
        initProperties();
        // add our route to the CamelContext
        context.addRoutes(new RouteBuilder() {
            public void configure() {
         //       from("file:D:\\tmp?recursive=true&delete=true&delay=5000").to("file:D:\\elk");
//            	from("timer:tick?period=3000")
//            	  .setBody().constant("Hello world from Camel K")
//            	  .to("log:info");
            }
        });
       // logger.info("message");
        // start the route and let it do its work
        context.start();
        Thread.sleep(600000);
        // stop the CamelContext
        context.stop();
	    }
	//init 
	public static void  initProperties()
	{
		Properties props = new Properties();//创建一个系统参数对象
		File filePath  =new File("log4j.properties");
		  try {
			  FileInputStream istream = new FileInputStream(filePath);//读取配置文件(log4j.properties)位置
			  props.load(istream);//将配置加载到系统参数对象中
			  PropertyConfigurator.configure(props);//装入log4j配置信息
		  }catch (Exception e) {
			// TODO: handle exception
		}
		
	}
}
